<?php

namespace app\api\model;

use think\Model;
use think\model\concern\SoftDelete;

/**
 * 订单详情
 */
class AfterOrderItem extends Model
{
    // protected static function base($query)
    // {
    //     $query->where('status',1);
    // }

    // protected $name='mall_goods';

    // 开启自动写入时间戳字段
    protected $auto_timestamp = 'false';

    // 设置json类型字段
    // protected $json = ['sf'];

    // 追加属性

    use SoftDelete;

    protected $deleteTime = 'delete_time';
 

    public function getSfAttr($value)
    {
        //  foreach($orderItem as $key1 => $v) {
        $sf_info_temp = json_decode($value, true);
        foreach ($sf_info_temp as $key => $value) {
            $body = array();
            for ($i = 0; $i < count($value['type_name']); $i++) {
                $body[$i]['type_name'] = $value['type_name'][$i];
                $body[$i]['value'] = $value['value'][$i];
            }
            $sf_info_temp[$key]['body'] = $body;
        }
        return $sf_info_temp;
        // $orderItem[$key1]['sf'] = $sf_info_temp;
        // }
    }
}
